 Imports MySql.Data.MySqlClient 
 Imports System.Data.OleDb
Imports System.Data.SqlClient
 Imports System .Data .SqlServerCe 
 Imports System.Data.OracleClient 
Imports System.Data
Imports DTO
Public Class HOCSINHDao
Inherits AbstractDao
 #Region "New" 
 Public Sub New(ByVal connection As KetNoiDto)
 MyBase.New(connection)
 End Sub
 Public Sub New( ByVal IDHOCSINH As System.Int32, ByVal connection As KetNoiDto)
 MyBase.New("HOCSINH", "select * from HOCSINH where IDHOCSINH=" & IDHOCSINH & "", connection)
 End Sub
 #End Region 
 Public Sub Them(ByVal Dto As HOCSINHDto)
 Dim strsql As String
 strsql = "Insert into HOCSINH(MAHOCSINH,IDPHUHUYNH,TENHOCSINH,NGAYSINH,GIOITINH,TRANGTHAI,GHICHU) values (?,?,?,?,?,?,?)
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 Dim cmd As New OleDbCommand(strsql, Ket_noi_access)
cmd.Parameters.Add("@MAHOCSINH", OleDbType.VarWChar)
cmd.Parameters.Add("@IDPHUHUYNH", OleDbType.Integer)
cmd.Parameters.Add("@TENHOCSINH", OleDbType.VarWChar)
cmd.Parameters.Add("@NGAYSINH", OleDbType.Date)
cmd.Parameters.Add("@GIOITINH", OleDbType.Integer)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters("@MAHOCSINH").Value = Dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = Dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = Dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = Dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = Dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New OleDbCommand(strsql, Ket_noi_access)
 Dto.IDHOCSINH = cmd.ExecuteScalar()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress
 strsql = "Insert into HOCSINH(MAHOCSINH,IDPHUHUYNH,TENHOCSINH,NGAYSINH,GIOITINH,TRANGTHAI,GHICHU) values (@MAHOCSINH,@IDPHUHUYNH,@TENHOCSINH,@NGAYSINH,@GIOITINH,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlCommand(strsql, Ket_noi_sql)
cmd.Parameters.Add("@MAHOCSINH", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDPHUHUYNH", SqlDbType.Int)
cmd.Parameters.Add("@TENHOCSINH", SqlDbType.NVarChar)
cmd.Parameters.Add("@NGAYSINH", SqlDbType.DateTime)
cmd.Parameters.Add("@GIOITINH", SqlDbType.Int)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters("@MAHOCSINH").Value = Dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = Dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = Dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = Dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = Dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New sqlCommand(strsql, Ket_noi_sql)
 Dto.IDHOCSINH = cmd.ExecuteScalar()
 Case Class_KieuDL.SqlCe
 strsql = "Insert into HOCSINH(MAHOCSINH,IDPHUHUYNH,TENHOCSINH,NGAYSINH,GIOITINH,TRANGTHAI,GHICHU) values (@MAHOCSINH,@IDPHUHUYNH,@TENHOCSINH,@NGAYSINH,@GIOITINH,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlceCommand(strsql, Ket_noi_SqlCe)
cmd.Parameters("@MAHOCSINH").Value = Dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = Dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = Dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = Dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = Dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strsql = "Insert into HOCSINH(MAHOCSINH,IDPHUHUYNH,TENHOCSINH,NGAYSINH,GIOITINH,TRANGTHAI,GHICHU) values (@MAHOCSINH,@IDPHUHUYNH,@TENHOCSINH,@NGAYSINH,@GIOITINH,@TRANGTHAI,@GHICHU)
 Dim cmd As New OracleCommand(strsql, Ket_noi_Oracle)
cmd.Parameters("@MAHOCSINH").Value = Dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = Dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = Dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = Dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = Dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Mysql
 strsql = "Insert into HOCSINH(MAHOCSINH,IDPHUHUYNH,TENHOCSINH,NGAYSINH,GIOITINH,TRANGTHAI,GHICHU) values (@MAHOCSINH,@IDPHUHUYNH,@TENHOCSINH,@NGAYSINH,@GIOITINH,@TRANGTHAI,@GHICHU)
 Dim cmd As New MySqlCommand(strsql, Ket_noi_MySql)
cmd.Parameters.Add("@MAHOCSINH", MySqlDbType.String)
cmd.Parameters.Add("@IDPHUHUYNH", MySqlDbType.Int32)
cmd.Parameters.Add("@TENHOCSINH", MySqlDbType.String)
cmd.Parameters.Add("@NGAYSINH",  MySqlDbType.DateTime)
cmd.Parameters.Add("@GIOITINH", MySqlDbType.Int32)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters("@MAHOCSINH").Value = Dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = Dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = Dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = Dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = Dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub Xoa( ByVal IDHOCSINH As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
strSQL = "Delete From HOCSINH Where IDHOCSINH= ? 
Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@IDHOCSINH",OleDbType.Integer).Value = IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
strSQL = "Delete From HOCSINH Where IDHOCSINH= @IDHOCSINH
Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@IDHOCSINH",SqlDbType.Int).value=IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
strSQL = "Delete From HOCSINH Where IDHOCSINH=" & IDHOCSINH & "
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
strSQL = "Delete From HOCSINH Where IDHOCSINH=" & IDHOCSINH & "
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
strSQL = "Delete From HOCSINH Where IDHOCSINH=" & IDHOCSINH & "
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub sua(ByVal dto As HOCSINHDto)
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update HOCSINH Set MAHOCSINH=? ,IDPHUHUYNH=? ,TENHOCSINH=? ,NGAYSINH=? ,GIOITINH=? ,TRANGTHAI=? ,GHICHU= ? where IDHOCSINH= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@MAHOCSINH", OleDbType.VarWChar)
cmd.Parameters.Add("@IDPHUHUYNH", OleDbType.Integer)
cmd.Parameters.Add("@TENHOCSINH", OleDbType.VarWChar)
cmd.Parameters.Add("@NGAYSINH", OleDbType.Date)
cmd.Parameters.Add("@GIOITINH", OleDbType.Integer)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
cmd.Parameters("@MAHOCSINH").Value = dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update HOCSINH Set MAHOCSINH= @MAHOCSINH , IDPHUHUYNH= @IDPHUHUYNH , TENHOCSINH= @TENHOCSINH , NGAYSINH= @NGAYSINH , GIOITINH= @GIOITINH , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@MAHOCSINH", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDPHUHUYNH", SqlDbType.Int)
cmd.Parameters.Add("@TENHOCSINH", SqlDbType.NVarChar)
cmd.Parameters.Add("@NGAYSINH", SqlDbType.DateTime)
cmd.Parameters.Add("@GIOITINH", SqlDbType.Int)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
cmd.Parameters("@MAHOCSINH").Value = dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update HOCSINH Set MAHOCSINH= @MAHOCSINH , IDPHUHUYNH= @IDPHUHUYNH , TENHOCSINH= @TENHOCSINH , NGAYSINH= @NGAYSINH , GIOITINH= @GIOITINH , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
cmd.Parameters("@MAHOCSINH").Value = dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update HOCSINH Set MAHOCSINH= @MAHOCSINH , IDPHUHUYNH= @IDPHUHUYNH , TENHOCSINH= @TENHOCSINH , NGAYSINH= @NGAYSINH , GIOITINH= @GIOITINH , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
cmd.Parameters("@MAHOCSINH").Value = dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update HOCSINH Set MAHOCSINH= @MAHOCSINH , IDPHUHUYNH= @IDPHUHUYNH , TENHOCSINH= @TENHOCSINH , NGAYSINH= @NGAYSINH , GIOITINH= @GIOITINH , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
cmd.Parameters.Add("@MAHOCSINH", MySqlDbType.String)
cmd.Parameters.Add("@IDPHUHUYNH", MySqlDbType.Int32)
cmd.Parameters.Add("@TENHOCSINH", MySqlDbType.String)
cmd.Parameters.Add("@NGAYSINH",  MySqlDbType.DateTime)
cmd.Parameters.Add("@GIOITINH", MySqlDbType.Int32)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters.Add("@IDHOCSINH", MySqlDbType.Int32)
cmd.Parameters("@MAHOCSINH").Value = dto.MAHOCSINH
cmd.Parameters("@IDPHUHUYNH").Value = dto.IDPHUHUYNH
cmd.Parameters("@TENHOCSINH").Value = dto.TENHOCSINH
cmd.Parameters("@NGAYSINH").Value = dto.NGAYSINH
cmd.Parameters("@GIOITINH").Value = dto.GIOITINH
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub SuaMAHOCSINH( ByVal MAHOCSINH as System.String, ByVal IDHOCSINH As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update HOCSINH Set MAHOCSINH = ?  where IDHOCSINH= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@MAHOCSINH", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
 cmd.Parameters("@MAHOCSINH").Value =  MAHOCSINH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update HOCSINH Set MAHOCSINH = @MAHOCSINH  where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@MAHOCSINH", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
 cmd.Parameters("@MAHOCSINH").Value =  MAHOCSINH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update HOCSINH Set MAHOCSINH =" & MAHOCSINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update HOCSINH Set MAHOCSINH =" & MAHOCSINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update HOCSINH Set MAHOCSINH =" & MAHOCSINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaIDPHUHUYNH( ByVal IDPHUHUYNH as System.Int32, ByVal IDHOCSINH As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update HOCSINH Set IDPHUHUYNH = ?  where IDHOCSINH= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDPHUHUYNH", OleDbType.Integer)
 cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
 cmd.Parameters("@IDPHUHUYNH").Value =  IDPHUHUYNH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update HOCSINH Set IDPHUHUYNH = @IDPHUHUYNH  where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDPHUHUYNH", SqlDbType.Int)
 cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
 cmd.Parameters("@IDPHUHUYNH").Value =  IDPHUHUYNH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update HOCSINH Set IDPHUHUYNH =" & IDPHUHUYNH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update HOCSINH Set IDPHUHUYNH =" & IDPHUHUYNH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update HOCSINH Set IDPHUHUYNH =" & IDPHUHUYNH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTENHOCSINH( ByVal TENHOCSINH as System.String, ByVal IDHOCSINH As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update HOCSINH Set TENHOCSINH = ?  where IDHOCSINH= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TENHOCSINH", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
 cmd.Parameters("@TENHOCSINH").Value =  TENHOCSINH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update HOCSINH Set TENHOCSINH = @TENHOCSINH  where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TENHOCSINH", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
 cmd.Parameters("@TENHOCSINH").Value =  TENHOCSINH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update HOCSINH Set TENHOCSINH =" & TENHOCSINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update HOCSINH Set TENHOCSINH =" & TENHOCSINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update HOCSINH Set TENHOCSINH =" & TENHOCSINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGAYSINH( ByVal NGAYSINH as System.DateTime, ByVal IDHOCSINH As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update HOCSINH Set NGAYSINH = ?  where IDHOCSINH= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGAYSINH", OleDbType.Date)
 cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
 cmd.Parameters("@NGAYSINH").Value =  NGAYSINH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update HOCSINH Set NGAYSINH = @NGAYSINH  where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGAYSINH", SqlDbType.DateTime)
 cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
 cmd.Parameters("@NGAYSINH").Value =  NGAYSINH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update HOCSINH Set NGAYSINH =" & NGAYSINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update HOCSINH Set NGAYSINH =" & NGAYSINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update HOCSINH Set NGAYSINH =" & NGAYSINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaGIOITINH( ByVal GIOITINH as System.Int32, ByVal IDHOCSINH As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update HOCSINH Set GIOITINH = ?  where IDHOCSINH= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@GIOITINH", OleDbType.Integer)
 cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
 cmd.Parameters("@GIOITINH").Value =  GIOITINH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update HOCSINH Set GIOITINH = @GIOITINH  where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@GIOITINH", SqlDbType.Int)
 cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
 cmd.Parameters("@GIOITINH").Value =  GIOITINH
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update HOCSINH Set GIOITINH =" & GIOITINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update HOCSINH Set GIOITINH =" & GIOITINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update HOCSINH Set GIOITINH =" & GIOITINH & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDHOCSINH As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update HOCSINH Set TRANGTHAI = ?  where IDHOCSINH= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
 cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update HOCSINH Set TRANGTHAI = @TRANGTHAI  where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
 cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update HOCSINH Set TRANGTHAI =" & TRANGTHAI & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update HOCSINH Set TRANGTHAI =" & TRANGTHAI & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update HOCSINH Set TRANGTHAI =" & TRANGTHAI & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaGHICHU( ByVal GHICHU as System.String, ByVal IDHOCSINH As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update HOCSINH Set GHICHU = ?  where IDHOCSINH= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update HOCSINH Set GHICHU = @GHICHU  where IDHOCSINH= @IDHOCSINH"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update HOCSINH Set GHICHU =" & GHICHU & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update HOCSINH Set GHICHU =" & GHICHU & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update HOCSINH Set GHICHU =" & GHICHU & "  where IDHOCSINH=" & IDHOCSINH & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub layBang()
 Chuoi_SQL = " Select * from HOCSINH
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDHOCSINH(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDHOCSINH=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from HOCSINH" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDHOCSINH(ByVal IDHOCSINH As System.Int32 )
 Chuoi_SQL = " Select * from HOCSINH where  IDHOCSINH = " & IDHOCSINH & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDHOCSINH(ByVal IDHOCSINH As System.Int32)
 Dim strsql As String
 strSQL = "Delete From HOCSINH Where IDHOCSINH=" & IDHOCSINH & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoMAHOCSINH(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "MAHOCSINH='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from HOCSINH" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoMAHOCSINH_like (ByVal MAHOCSINH As System.String )
 Chuoi_SQL = " Select * from HOCSINH where  MAHOCSINH  like '%" & MAHOCSINH & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoMAHOCSINH(ByVal MAHOCSINH As System.String )
 Chuoi_SQL = " Select * from HOCSINH where  MAHOCSINH = '" & MAHOCSINH & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoMAHOCSINH(ByVal MAHOCSINH As System.String)
 Dim strsql As String
 strSQL = "Delete From HOCSINH Where MAHOCSINH='" & MAHOCSINH & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDPHUHUYNH(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDPHUHUYNH=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from HOCSINH" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDPHUHUYNH(ByVal IDPHUHUYNH As System.Int32 )
 Chuoi_SQL = " Select * from HOCSINH where  IDPHUHUYNH = " & IDPHUHUYNH & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDPHUHUYNH(ByVal IDPHUHUYNH As System.Int32)
 Dim strsql As String
 strSQL = "Delete From HOCSINH Where IDPHUHUYNH=" & IDPHUHUYNH & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTENHOCSINH(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TENHOCSINH='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from HOCSINH" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTENHOCSINH_like (ByVal TENHOCSINH As System.String )
 Chuoi_SQL = " Select * from HOCSINH where  TENHOCSINH  like '%" & TENHOCSINH & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoTENHOCSINH(ByVal TENHOCSINH As System.String )
 Chuoi_SQL = " Select * from HOCSINH where  TENHOCSINH = '" & TENHOCSINH & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTENHOCSINH(ByVal TENHOCSINH As System.String)
 Dim strsql As String
 strSQL = "Delete From HOCSINH Where TENHOCSINH='" & TENHOCSINH & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGAYSINH(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGAYSINH='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from HOCSINH" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGAYSINH(ByVal NGAYSINH As System.DateTime )
 Chuoi_SQL = " Select * from HOCSINH where  NGAYSINH = @Ngay
 Doc_bang_Dk_ngay(NGAYSINH)
 End Sub
 Public Sub layBangTheoNGAYSINH(ByVal NGAYSINH1 As System.DateTime,ByVal NGAYSINH2 As System.DateTime )
 Chuoi_SQL = " Select * from HOCSINH where  NGAYSINH >= @Ngay and NGAYSINH <= @denNgay ORDER BY NGAYSINH
 Doc_bang_Dk_ngay(NGAYSINH1,NGAYSINH2)
 End Sub
 Public Sub XOABangTheoNGAYSINH(ByVal NGAYSINH As System.DateTime)
 Dim strsql As String
 strSQL = "Delete From HOCSINH Where NGAYSINH='" & NGAYSINH & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoGIOITINH(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "GIOITINH=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from HOCSINH" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoGIOITINH(ByVal GIOITINH As System.Int32 )
 Chuoi_SQL = " Select * from HOCSINH where  GIOITINH = " & GIOITINH & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoGIOITINH(ByVal GIOITINH As System.Int32)
 Dim strsql As String
 strSQL = "Delete From HOCSINH Where GIOITINH=" & GIOITINH & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TRANGTHAI=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from HOCSINH" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32 )
 Chuoi_SQL = " Select * from HOCSINH where  TRANGTHAI = " & TRANGTHAI & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32)
 Dim strsql As String
 strSQL = "Delete From HOCSINH Where TRANGTHAI=" & TRANGTHAI & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoGHICHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "GHICHU='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from HOCSINH" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU_like (ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from HOCSINH where  GHICHU  like '%" & GHICHU & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU(ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from HOCSINH where  GHICHU = '" & GHICHU & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoGHICHU(ByVal GHICHU As System.String)
 Dim strsql As String
 strSQL = "Delete From HOCSINH Where GHICHU='" & GHICHU & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangNhieuTable
 Chuoi_SQL = " Select IDHOCSINH ,MAHOCSINH ,IDPHUHUYNH ,TENHOCSINH ,NGAYSINH ,GIOITINH ,TRANGTHAI ,GHICHU  from HOCSINH"
 Doc_bang()
 End sub
Public Sub TaoTable()
Dim strsql As String
strsql = ""
Select Case ketnoi.MsSql
Case Class_KieuDL.Access 
Case Class_KieuDL.Sql, Class_KieuDL.sqlExpress
strsql = ""
Case Class_KieuDL.SqlCe
strsql = ""
Case Class_KieuDL.Oracle
strsql = ""
Case else 
strsql = ""
End Select
Thuc_hien_lenh(strsql)
End Sub
 End Class

